package com.fishingwithme.infrastructure.dtos.circle;

import com.fishingwithme.domain.spots.FishType;
import com.fishingwithme.domain.spots.HarvestType;
import com.fishingwithme.infrastructure.dtos.anybiting.MessageContentBody;
import com.fishingwithme.infrastructure.utils.CommonUtils;
import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.Data;

import java.util.Date;
import java.util.List;

@Data
public class CircleHarvestShowDto implements MessageContentBody {
    private Long id;
    private List<String> pics;
    private String pictures;

    private String fishHarvest;
    private List<ObjectNode> fHarvests;

    private String harvestType;
    private ObjectNode hType;

    private Double score;
    private Date fishingAt;
    private Long fisherId;


    @Override
    public void format() {
        try {
            if (this.getFishHarvest() != null) {
                this.setFHarvests(CommonUtils.convert(this.getFishHarvest(), FishType.class));
                this.setFishHarvest(null);
            }
            if (this.getPictures() != null) {

                this.setPics(CommonUtils.convert(this.getPictures(), String.class));
                this.setPictures(null);
            }
            if (this.getHarvestType() != null) {
                this.setHType(HarvestType.valueOf(this.getHarvestType()).toJson());
                this.setHarvestType(null);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
